package com.leetcode.partition22;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author `RKC`
 * @date 2022/3/6 21:54
 */
public class LC2100适合打劫银行的日子 {

    private static final int N = 100010;
    private static int[] s1 = new int[N], s2 = new int[N], temp = new int[N];
    private static int n;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]);
        int[] security = new int[n];
        ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) security[i] = Integer.parseInt(ss[i]);
        writer.write(goodDaysToRobBank(security, m).toString());
        writer.flush();
    }

    public static List<Integer> goodDaysToRobBank(int[] security, int time) {
        n = security.length;
        List<Integer> ans = new ArrayList<>(n);
        //对于每一位数字，如果当前数字大于前一个数，记录为1，小于为-1，相等则为0
        for (int i = 1; i < n; i++) {
            if (security[i] > security[i - 1]) temp[i] = 1;
            else if (security[i] < security[i - 1]) temp[i] = -1;
        }
        //前缀和思想统计1和-1的数量
        for (int i = 1; i <= n; i++) {
            if (temp[i - 1] == 1) s1[i] = s1[i - 1] + temp[i - 1];
            else s1[i] = s1[i - 1];
            if (temp[i - 1] == -1) s2[i] = s2[i - 1] - temp[i - 1];
            else s2[i] = s2[i - 1];
        }
        for (int i = time; i < n - time; i++) {
            if (s1[i + 1] - s1[i + 1 - time] == 0 && s2[i + 1 + time] - s2[i + 1] == 0) {
                ans.add(i);
            }
        }
        return ans;
    }
}
